package com.zls.dubbo.controller;

import com.zls.dubbo.service.DeviceService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("device")
public class DerviceController {
    //    @Reference(version = "default")   //dubbo包下
//    @Reference
//    @Reference(loadbalance = "roundrobin") //指定负载均衡策略为轮询
    @Reference(loadbalance = "roundrobin",mock = "com.com.zls.dubbo.service.impl.MyDerviceMock")
    private DeviceService deviceService;

    @GetMapping("/{id}")
    public String findById(@PathVariable(name = "id") Integer id) {

        String name = deviceService.showDevice(id);
        System.out.println("消费者---------");
        return "DeviceController--> " + name;
    }
}
 